<template>

	<view>
		<block v-if="type==1">
			<view class="group">
				<view class="lab">和我组局需要费用</view>
				<view class="inp_box_r">
					<u-switch :value="reqData.IsFee == 1" activeColor="#E0C48D" @change="setIsFee" size="20"></u-switch>
				</view>
			</view>

			<view class="group" v-if="reqData.IsFee == 1">
				<view class="lab">组局费用</view>
				<view class="inp_box">
					<input v-model="reqData.PlayFee" type="decimal" placeholder="请输入费用" />
				</view>
			</view>
		</block>
		<block v-if="type==2">
			<!-- <view class="group">
			<view class="lab">加我微信需要鲜花</view>
			<view class="inp_box">
				<input v-model="reqData.AddWechatFee" type="decimal" placeholder="请输入数量" />
			</view>
		</view> -->
			<!-- <view class="title">
				<text>隐私设置</text>
			</view> -->
			<view class="group">
				<view class="lab lab_badge flx flx_align_center">
					<view class="">
						不显示位置
					</view>
					<image class="right_badge" src="https://golfdate.oss-cn-shenzhen.aliyuncs.com/img/2.png" mode=""></image>
				</view>
				<view class="inp_box_r">
					<u-switch :value="reqData.IsHideCity == 1" activeColor="#E0C48D" @change="setIsHideCity"
						size="20"></u-switch>
				</view>
			</view>
			<view class="group">
				<view class="lab lab_badge flx flx_align_center">
					<view class="">
						不在首页看到我
					</view>
					<image class="right_badge" src="https://golfdate.oss-cn-shenzhen.aliyuncs.com/img/2.png" mode=""></image>
				</view>
				<view class="inp_box_r">
					<u-switch :value="reqData.IsOpenMember == 1" activeColor="#E0C48D" @change="setIsOpenMember"
						size="20"></u-switch>
				</view>
			</view>

			<view class="group">
				<view class="lab lab_badge flx flx_align_center">
					<view class="">
						隐藏我的好友关系
					</view>
					<image class="right_badge" src="https://golfdate.oss-cn-shenzhen.aliyuncs.com/img/2.png" mode=""></image>
				</view>
				<view class="inp_box_r">
					<u-switch :value="reqData.IsHideFriend == 1" activeColor="#E0C48D" @change="setIsHideFriend"
						size="20"></u-switch>
				</view>
			</view>

			<view class="group">
				<view class="lab lab_badge flx flx_align_center">
					<view class="">
						头像蒙脸不让看
					</view>
					<image class="right_badge" src="https://golfdate.oss-cn-shenzhen.aliyuncs.com/img/2.png" mode=""></image>
				</view>

				<view class="inp_box_r">
					<u-switch :value="reqData.IsHideFace == 1" activeColor="#E0C48D" @change="setIsHideFace" size="20"></u-switch>
				</view>
			</view>
		</block>
		<block v-if="type==3">
			<view class="title">
				<text>提现设置</text>
			</view>
			<view class="group">
				<view class="lab">{{F001}}</view>
				<view class="inp_box">
					<input v-model="reqData.Bank" type="text" disabled="true" />
				</view>
			</view>
			<view class="group">
				<view class="lab">{{F003}}</view>
				<view class="inp_box">
					<input v-model="reqData.BankAccountName" type="text" placeholder="请输入" />
				</view>
			</view>
			<view class="group">
				<view class="lab">{{F002}}</view>
				<view class="inp_box">
					<input v-model="reqData.BankAccount" type="text" placeholder="请输入" />
				</view>
			</view>
		</block>
		<!-- <view class="title">
			<text>公会设置</text>
		</view>
		<view class="group">
			<view class="lab">MCN机构</view>
			<view class="inp_box">
				<input v-model="reqData.MCN" placeholder="MCN编号" />
			</view>
		</view>
		<view class="group">
			<view class="lab">球队队长GD号</view>
			<view class="inp_box">
				<input v-model="reqData.TeamID" placeholder="队长GD号" />
			</view>
		</view>
 -->
		<view class="btn_wrap" @click="saveFee">
			<view class="fee_btn">保存</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				type: 0,
				reqData: {
					PlayFee: 0,
					IsFee: 0,
					IsOpenMember: 0,
					IsHideFriend: 0,
					AddWechatFee: 0,
					IsHideFace: 0,
					MCN: '',
					UserType: '',
					Bank: '支付宝',
					BankAccount: '',
					BankAccountName: ''
				},
				
				F001:'',
				F002:'',
				F003:''
			};
		},
		async onLoad(e) {
			this.type = e.type
			let u = uni.getStorageSync('user');
			let res = await this.$api.post('User/GetUserInfo', {
				ID: u.UserID
			});
			this.reqData = {
				...res.data
			};


			let dic = await this.$api.post('Catalog/GetDictionary', {
				Type: '提现字段'
			});
			
			if(dic.data){
				this.F001=dic.data[0].ValueStr;
				this.F002=dic.data[1].ValueStr;
				this.F003=dic.data[2].ValueStr;
			}
			
			//this.reqData.Bank = '支付宝'
		},
		methods: {
			setIsFee(e) {
				this.reqData.IsFee = e ? 1 : 0;
			},
			setIsOpenMember(e) {
				let _this = this;
				if (this.reqData.UserType != '黑金卡会员' && this.reqData.UserType != '黑金年卡会员') {
					uni.showModal({
						title: '温馨提示',
						content: '此设置为黑金卡专属',
						confirmText: "去开通",
						success: function(res) {
							if (res.confirm) {
								_this.nav_to('/pages/user/apply_member');
							} else if (res.cancel) {

							}
						}
					});
				} else {

					this.reqData.IsOpenMember = e ? 1 : 0
				}
			},
			setIsHideCity(e) {
				let _this = this;
				if (this.reqData.UserType != '黑金卡会员' && this.reqData.UserType != '黑金年卡会员') {
					uni.showModal({
						title: '温馨提示',
						content: '此设置为黑金卡专属',
						confirmText: "去开通",
						success: function(res) {
							if (res.confirm) {
								_this.nav_to('/pages/user/apply_member');
							} else if (res.cancel) {
			
							}
						}
					});
				} else {
			
					this.reqData.IsHideCity = e ? 1 : 0
				}
			},
			setIsHideFriend(e) {
				let _this = this;
				if (this.reqData.UserType != '黑金卡会员' && this.reqData.UserType != '黑金年卡会员') {
					uni.showModal({
						title: '温馨提示',
						content: '此设置为黑金卡专属',
						confirmText: "去开通",
						success: function(res) {
							if (res.confirm) {
								_this.nav_to('/pages/user/apply_member');
							} else if (res.cancel) {

							}
						}
					});
				} else {

					this.reqData.IsHideFriend = e ? 1 : 0
				}
			},
			setIsHideFace(e) {
				let _this = this;
				if (this.reqData.UserType != '黑金卡会员' && this.reqData.UserType != '黑金年卡会员') {
					uni.showModal({
						title: '温馨提示',
						content: '此设置为黑金卡专属',
						confirmText: "去开通",
						success: function(res) {
							if (res.confirm) {
								_this.nav_to('/pages/user/apply_member');
							} else if (res.cancel) {

							}
						}
					});
				} else {

					this.reqData.IsHideFace = e ? 1 : 0
				}
			},
			async saveFee() {
				let res = await this.$api.post('Member/SaveFeeSettings', {
					IsFee: this.reqData.IsFee,
					PlayFee: this.reqData.PlayFee,
					IsOpenMember: this.reqData.IsOpenMember,
					IsHideFriend: this.reqData.IsHideFriend,
					MCN: this.reqData.MCN,
					IsHideFace: this.reqData.IsHideFace,
					Bank: this.reqData.Bank,
					BankAccount: this.reqData.BankAccount,
					BankAccountName: this.reqData.BankAccountName,
					IsHideCity:this.reqData.IsHideCity
				});
				console.log(res);
				if (res.data) {
					this.$pv.msg('保存成功');
					setTimeout(() => {
						uni.navigateBack();
					}, 1000);
				} else {
					this.$pv.msg('保存失败');
				}
			}
		}
	};
</script>

<style lang="scss">
	page {
		background-color: #f6f6f6;
	}

	.title {
		padding: 20rpx 24rpx;
	}

	.group {
		display: flex;
		align-items: center;
		justify-content: space-between;
		background-color: #fff;
		padding: 0 24rpx;
		flex-wrap: wrap;
		margin-top: 20rpx;
		.inp_box {
			flex: 1;

			input {
				width: 100%;
				text-align: right;
			}
		}

		.icon_box {
			height: 40rpx;
			width: 40rpx;
			line-height: 40rpx;
		}

		.lab {
			height: 110rpx;
			padding-right: 10rpx;
			color: #333333;
			font-size: 32rpx;
			line-height: 110rpx;
		}

		.right_badge {
			margin-left: 16rpx;
			width: 36rpx;
			height: 36rpx;
		}

		.lab_badge {
			view {
				color: #333333;
                font-size: 32rpx;
			}
		}

	}

	.btn_wrap {
		padding: 0 30rpx;
	}

	.fee_btn {
		margin-top: 46rpx;
		border-radius: 50rpx;
		font-size: 32rpx;
		letter-spacing: 3px;

		padding: 20rpx 40rpx;
		text-align: center;
		color: #fff;
		background: #0D0D0D;
		position: relative;
	}
</style>